---
title: useUpdateBreakpointEffect
description: "`useUpdateBreakpointEffect`は、初回のレンダリング時にはエフェクトをスキップし、ブレイクポイントが変更されたときにエフェクトを実行するカスタムフックです。"
storybook: hooks-useupdatebreakpointeffect--basic
source: hooks/use-breakpoint
---

```tsx preview functional client
const [device, setDevice] = useState("unknown");

useUpdateBreakpointEffect(breakpoint => {
  if (breakpoint === "sm") {
    setDevice("mobile");
  } else if (breakpoint === "md") {
    setDevice("tablet");
  } else {
    setDevice("desktop");
  }
}, []);

return <Text>The current device is "{device}"</Box>;
```

## 使い方

:::code-group

```tsx [package]
import { useUpdateBreakpointEffect } from "@yamada-ui/react"
```

```tsx [alias]
import { useUpdateBreakpointEffect } from "@/components/ui"
```

```tsx [monorepo]
import { useUpdateBreakpointEffect } from "@workspaces/ui"
```

:::

```tsx
const [device, setDevice] = useState("unknown")

useUpdateBreakpointEffect((breakpoint) => {
  if (breakpoint === "sm") {
    setDevice("mobile")
  } else if (breakpoint === "md") {
    setDevice("tablet")
  } else {
    setDevice("desktop")
  }
}, [])
```
